package de.urw.core;

import java.util.ArrayList;

import android.util.Log;

public class URWedge
{
	public int id;
	public URWnode source;
	public URWnode sink;
	public int sourceId;
	public int sinkId;
	public boolean initialized = false;
	
	public URWedge(int id, URWnode source, URWnode sink)
	{
		this.id = id;
		this.source = source;
		this.sink = sink;
	}
	
	public URWedge(int id, int sourceId, int sinkId)
	{
		this.id = id;
		this.sourceId = sourceId;
		this.sinkId = sinkId;
		source = null;
		sink = null;
	}
	
	public boolean init(ArrayList<URWnode> list)
	{
		if(source == null)
		{
			//Log.d("test", "src null: " + sourceId);
			//source = list.get(sourceId);
			
			for(URWnode node : list)
			{
				if(node.id == sourceId)
				{
					source = node;
					break;
				}
			}
			
		}
		
		if(sink == null)
		{
			//sink = list.get(sinkId);
			//Log.d("test", "sink null: " + sinkId);
			
			for(URWnode node : list)
			{
				if(node.id == sinkId)
				{
					sink = node;
					break;
				}
			}
		}
		
		Log.d("test", "init!");
		
		if(source != null && sink != null) {
			initialized = true;
			return true;
		}
		else return false;
	}
}
